unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,JY_Chart, StdCtrls, ExtCtrls,DbChart,Series, TeeProcs, TeEngine,
  Chart, TeeFunci;

type
  TJYChartDisplayABX=class(TJYChartOfDot)
  private
    FDBChart1: TDBChart;
    FLineSeries1: TLineSeries;
    FDBChart2: TDBChart;
    FLineSeries2: TLineSeries;
    FDBChart3: TDBChart;
    FLineSeries3: TLineSeries;
    FJYChartData:TJYChartData;
  private
    procedure AdjustChartSize;
  public
    constructor Create(pYQBM: string; pJYRQ, pYBH: integer; pChartPanle: TPanel);override;
    destructor Destroy; override;
    procedure ViewChart;override;
    procedure SetImageList(AList:TList);override;
  end;


  TFormMain = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    Chart1: TChart;
    Series1: TLineSeries;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
   FJYChart : TJYChartDisplayABX;
  public
    { Public declarations }
  end;

var
  FormMain: TFormMain;

implementation
uses Pub_Data,Pub_DataLis;
{$R *.dfm}

{ TJYChartDisplayABX }

procedure TJYChartDisplayABX.AdjustChartSize;
var
  vHeight, vWidth:integer;
begin
  vHeight:=FChartPanel.Height div 3;
  vWidth:=FChartPanel.Width;
  with FDBChart1 do
  begin
    Left:=0;
    Top:=0;
    Height:=vHeight;
    Width:=vWidth;
  end;
  with FDBChart2 do
  begin
    Left:=0;
    Top:=vHeight;
    Height:=vHeight;
    Width:=vWidth;
  end;
  with FDBChart3 do
  begin
    Left:=0;
    Top:=2*vHeight;
    Height:=FChartPanel.Height-2*vHeight;
    Width:=vWidth;
  end;

end;

constructor TJYChartDisplayABX.Create(pYQBM: string; pJYRQ, pYBH: integer;
  pChartPanle: TPanel);
var
  vYQModel:string;
begin
  inherited Create(pYQBM, pJYRQ, pYBH, pChartPanle);
  vYQModel:=PubDataLis.PubProc.GetYQModel(pYQBM);
  FJYChartData:=TJYChartData.Create(vYQModel, pYQBM, pJYRQ, pYBH);
  FDBChart1 := TDBChart.Create(nil);
  FLineSeries1 := TLineSeries.Create(FDBChart1);
  FDBChart2 := TDBChart.Create(nil);
  FLineSeries2 := TLineSeries.Create(FDBChart2);
  FDBChart3 := TDBChart.Create(nil);
  FLineSeries3 := TLineSeries.Create(FDBChart3);

end;

destructor TJYChartDisplayABX.Destroy;
begin
  FDBChart1.Free;
  FDBChart2.Free;
  FDBChart3.Free;
  FJYChartData.Free;
  inherited Destroy;
end;

procedure TJYChartDisplayABX.SetImageList(AList: TList);
begin
  ViewChart;
  AList.Add(CreateImage(FDBChart1));
  AList.Add(CreateImage(FDBChart2));
  AList.Add(CreateImage(FDBChart3));

end;

procedure TJYChartDisplayABX.ViewChart;
begin
  with FDBChart1 do
  begin
    Visible:=True;
    View3D:=False;
  //  Legend.Visible:=False;
    BevelOuter:=bvNone;
    BevelInner:=bvNone;
    BorderStyle:=bsNone;
    Color:=clWindow;
    Parent:=FChartPanel;
    SeriesList.Add(FLineSeries1);
    Title.Text.Clear;
    Title.Text.Add('RBC');
    LeftAxis.Visible:=True;
    BottomAxis.Visible:=True;
    BottomAxis.Grid.Visible:=False;
  //  BottomAxis.Increment:=100;

    LeftAxis.Automatic := False;
    LeftAxis.Maximum := 400;
  //  LeftAxis.Minimum := 32;
    LeftAxis.AutomaticMinimum := True;
    LeftAxis.Visible:=True;
    LeftAxis.Labels := False;
    Frame.Visible := False;
  end;
  with FLineSeries1 do
  begin
    ParentChart:=FDBChart1;
    DataSource:=FJYChartData.GetDataSet('RBC');
    XValues.ValueSource:='PosX';
    YValues.ValueSource:='PosY';
  end;

  with FDBChart2 do
  begin
    Visible:=True;
    Parent:=FChartPanel;
    View3D:=False;
    Legend.Visible:=False;
    BevelOuter:=bvNone;
    BevelInner:=bvNone;
    BorderStyle:=bsNone;
    Color:=clWindow;
    SeriesList.Add(FLineSeries2);
    Title.Text.Clear;
    Title.Text.Add('PLT');
    LeftAxis.Visible:=False;
    BottomAxis.Visible:=True;
    BottomAxis.Increment:=10;
    BottomAxis.Grid.Visible:=False;

    LeftAxis.Automatic := False;
    LeftAxis.Maximum := 400;
  //  LeftAxis.Minimum := 32;
    LeftAxis.AutomaticMinimum := True;
  end;
  with FLineSeries2 do
  begin
    ParentChart:=FDBChart2;
    DataSource:=FJYChartData.GetDataSet('PLT');
    XValues.ValueSource:='PosX';
    YValues.ValueSource:='PosY';
  end;

  with FDBChart3 do
  begin
    Visible:=True;
    Parent:=FChartPanel;
    View3D:=False;
    Legend.Visible:=False;
    BevelOuter:=bvNone;
    BevelInner:=bvNone;
    BorderStyle:=bsNone;
    Color:=clWindow;
    SeriesList.Add(FLineSeries3);
    Title.Text.Clear;
    Title.Text.Add('BAS');
    LeftAxis.Visible:=False;
    BottomAxis.Visible:=True;
  //  BottomAxis.Increment:=100;
    BottomAxis.Grid.Visible:=False;

    LeftAxis.Automatic := False;
    LeftAxis.Maximum := 100;
    LeftAxis.AutomaticMinimum := True;
  //  LeftAxis.Minimum := 32;
  end;
  with FLineSeries3 do
  begin
    ParentChart:=FDBChart3;
    DataSource:=FJYChartData.GetDataSet('BAS');
    XValues.ValueSource:='PosX';
    YValues.ValueSource:='PosY';
  end;
  if Assigned(FChartPanel) then
    AdjustChartSize;

end;

{TFormMain}

procedure TFormMain.FormCreate(Sender: TObject);
begin
  PubDataManager.CreatePubData(TPubDataLis, TPubData(PubDataLis));
  FJYChart := TJYChartDisplayABX.Create('0000',41065,0,Panel1);
end;

procedure TFormMain.FormDestroy(Sender: TObject);
begin
  FJYChart.Free;
  PubDataManager.FreePubData(TPubData(PubDataLis));
end;

procedure TFormMain.Button1Click(Sender: TObject);
begin
  FJYChart.ViewChart;
end;

end.
